package com.mccrea.pattern.factory.absfactory.pizzastore.order;

import com.mccrea.pattern.factory.absfactory.pizzastore.pizza.Pizza;
import com.mccrea.pattern.factory.util.InputUtil;

/**
 * @Classname OrderPizza
 * @Description Pizza订单
 * @Date 2021/5/7 0007 19:21
 * @Created by Mccrea_Gao
 */
public class OrderPizza {
    IFactory iFactory;

    public OrderPizza(IFactory iFactory) {
        setFactory(iFactory);
    }

    private void setFactory(IFactory iFactory) {
        this.iFactory = iFactory;
        Pizza pizza;
        String orderType;
        do {
            orderType = InputUtil.getType();
            pizza = iFactory.createPizza(orderType);
            if (pizza != null) {
                pizza.prepare();
                pizza.bake();
                pizza.cut();
                pizza.box();
            } else {
                System.out.println("没有指定pizza");
                break;
            }

        } while (true);
    }

}
